import { getActiveStr } from "../../../../utils/utilsNew"

// pages/zxdk/com-house-item/com-house-item.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    model: {
      type: Object,
      value: {}
    }
  },

  options: {
    styleIsolation: 'apply-shared',
    addGlobalClass: true,
  },
  /**
   * 组件的初始数据
   */
  data: {
    _model: {},
    isSelected: false 
  },

  observers: {
    model() {
      // console.log("model change");
      
      let model = this.data.model
      let result = {...model}
      result.smallIngUrl = result.smallIngUrl || "/images/defaultImgSmall.jpg"
      result.brokerImgUrl = result.brokerImgUrl || "/images/default_head.png"
      result.title = getActiveStr(result.title, 44)
      this.setData({
        _model: result
      })
    }
  },

  /**
   * 组件的方法列表
   */
  methods: {
    handleSelect() {
      this.triggerEvent('onselecthouse', {isSelected: !this.data._model.isSelected, id: this.data._model.hou_del_id})
    },
  }
})
